﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Citi.PTSConsolidation.Domain;

namespace Citi.PTSConsolidation.WebUi.Models
{
    public class FinancialTypeModel
    {
        public int Id { get; set; }
        public string AccountLevel1 { get; set; }
        public string AccountLevel2 { get; set; }
        public string AccountLevel3 { get; set; }
        public string LineType { get; set; }

        public static FinancialTypeModel CreateModel(FinancialType domain)
        {
            return new FinancialTypeModel
            {
                Id = domain.Id,
                AccountLevel1 = domain.AccountLevel1,
                AccountLevel2 = domain.AccountLevel2,
                AccountLevel3 = domain.AccountLevel3,
                LineType = domain.LineType
            };
        }

        public static IEnumerable<FinancialTypeModel> CreateModel(IEnumerable<FinancialType> domain)
        {
            return domain.Select(CreateModel);
        } 
        
        public static FinancialType CreateDomain(FinancialTypeModel model)
        {
            return new FinancialType
            {
                Id = model.Id,
                AccountLevel1 = model.AccountLevel1,
                AccountLevel2 = model.AccountLevel2,
                AccountLevel3 = model.AccountLevel3,
                LineType = model.LineType
            };
        }

        public static IEnumerable<FinancialType> CreateDomain(IEnumerable<FinancialTypeModel> model)
        {
            return model.Select(CreateDomain);
        }
    }
}